home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Popular Request
/
By Popular Request (Arsenal Computer)(SysOptics Distribution System).ISO
/
amiga1
/
chkdbl10.lha
/
MyStartup.a
< prev
next >
Wrap
Text File
|
1994-01-16
|
2KB
|
119 lines
* This is a minimal startup code.
AbsExecBase EQU $00000004
include "dos/dosextens.i"
include "workbench/startup.i"
include "exec/funcdef.i"
include "exec/exec_lib.i"
include "dos/dos_lib.i"
xref _LinkerDB
xref __BSSBAS
xref __BSSLEN
section text,code
xdef @exit
xref _main
*************************************************
Begin:
lea __BSSBAS,a1 ; clear BSS segment
move.l #__BSSLEN,d1
bra.s ClearBSS
ClearBSSLoop:
clr.l (a1)+
ClearBSS:
dbf d1,ClearBSSLoop
lea _LinkerDB,a4 ; save stackpointer
move.l SP,StackPtr(a4)
move.l AbsExecBase.w,a6 ; load SysBase
move.l a6,_SysBase(a4)
move.l a0,_Startup(a4) ; assume CLI startup
move.l d0,_CommandLineLength(a4)
sub.l a1,a1 ; get our process structure
jsr _LVOFindTask(a6)
move.l d0,a0
tst.l pr_CLI(a0) ; check for CLI or workbench
bne.s OpenDOS
WorkbenchStartup:
lea pr_MsgPort(a0),a0 ; wait for workbench message
move.l a0,a2
jsr _LVOWaitPort(a6)
move.l a2,a0 ; and get it
jsr _LVOGetMsg(a6)
move.l d0,_Startup(a4)
clr.l _CommandLineLength(a4)
OpenDOS:
lea DosName(PC),a1 ; open dos.library
moveq #0,d0
jsr _LVOOpenLibrary(a6)
move.l d0,_DOSBase(a4)
beq.s StartupNoDOS
tst.l _CommandLineLength(a4) ; if we were run from workbench,
bne.s RunMain
move.l d0,a6
move.l _Startup(a4),a0 ; set our current dir
move.l sm_ArgList(a0),d0
beq.s RunMain
move.l d0,a0
move.l wa_Lock(a0),d1
jsr _LVOCurrentDir(a6)
RunMain:
bsr _main ; run my main C function
moveq #0,d0
@exit:
move.l StackPtr(a4),SP ; restore stackpointer
move.l d0,-(SP) ; save returncode
CloseDOS:
move.l _DOSBase(a4),a1 ; close dos.library
move.l AbsExecBase.w,a6
jsr _LVOCloseLibrary(a6)
ExitNoDOS:
tst.l _CommandLineLength(a4) ; check whether we need to reply to
bne.s Exit ; Workbench
jsr _LVOForbid(a6) ; reply to Workbench
move.l _Startup(a4),a1
jsr _LVOReplyMsg(a6)
Exit: move.l (SP)+,d0 ; get returncode
rts
StartupNoDOS:
moveq #100,d0
bra.s ExitNoDOS
DosName: dc.b "dos.library",0
*************************************************
section __MERGED,BSS
xdef _SysBase
xdef _DOSBase
xdef _CommandLineLength
xdef _Startup
StackPtr ds.l 1
_SysBase ds.l 1
_DOSBase ds.l 1
_CommandLineLength ds.l 1
_Startup ds.l 1
END